package com.zhuhao.thinking.in.java;

import java.util.Arrays;

/**
 * 几种初始化数组的方式
 * @Author haozhu7
 * @Date 2023/9/17 21:34
 **/
public class ArrayDemo {

    public static void main(String[] args) {
        //1
        String[] strArray = new String[6];

        for (int i = 0; i < 6; i++) {
            strArray[i] = "i = " + i;
        }

        System.out.println(Arrays.toString(strArray));

        //2
        String[] strArray2 = {"1", "2", "3", "4"};
        //3
        String[] strArray3 = new String[]{"5", "6", "7"};
        //4
        String[] strArray4;

        //这种方式不可以
//        strArray4 = {"2"};
        strArray4 = new String[]{"22", "33"};

        System.out.println(Arrays.toString(strArray2));
        System.out.println(Arrays.toString(strArray3));
        System.out.println(Arrays.toString(strArray4));

    }
}
